﻿<%<hi:common_new_header runat="server" skinname="/ascx/JsNewTags/Skin-Common_New_Header.ascx" />%>
<script type="text/javascript">
    $(document).ready(function () {
        $("#btnLoginAndBuy").bind("click", function () { LoginAndCheck(); });
        $("#btnAmoBuy").bind("click", function () { window.location.href = applicationPath + "/SubmmitOrder.aspx"; });
        $("#textfieldusername").keydown(function (e) { if (e.keyCode == 13) { LoginAndCheck(); return false; } });
        $("#textfieldpassword").keydown(function (e) { if (e.keyCode == 13) { LoginAndCheck(); return false; } });
    });
    function CloseLogin() {
        $("#loginForBuy").hide('hide');
    }
    function GoToCheck() {
        if ($("#ShoppingCart_hfdIsLogin").val() == "logined")
            return true;

        $("#loginForBuy").show('hide');
        return false;
    }
    // 登录后再购买
    function LoginAndCheck() {
        var username = $("#textfieldusername").val();
        var password = $("#textfieldpassword").val();
        var thisURL = document.URL;

        if (username.length == 0 || password.length == 0) {
            alert("请输入您的用户名和密码!");
            return;
        }


        $.ajax({
            url: "Login.aspx",
            type: "post",
            dataType: "json",
            timeout: 10000,
            data: { username: username, password: password, action: "Common_UserLogin" },
            async: false,
            success: function (data) {
                if (data.Status == "Succes") {
                    $("#loginForBuy").hide('hide');
                    $("#hiddenIsLogin").val('logined');
                    window.location.href = applicationPath + "/SubmmitOrder.aspx";
                }
                else {
                    alert(data.Msg);
                }
            }
        });
    }
</script>
<form runat="server">
    <div id="msgtip" style="width: 1000px; margin: 0 auto; color: red;">
        <%<hi:smallstatusmessage id="Status" runat="server" width="200" visible="False" />%>
    </div>
    <div class="cart_h">
        <div id="logo">
            <hi:common_logo id="Common_Logo1" runat="server" />
        </div>
        <div class="cart_step">
            <ul class="cart_step1">
                <li class="step-1"><b></b>1.我的购物车</li>
                <li class="step-2"><b></b>2.填写核对订单信息</li>
                <li class="step-3">3.成功提交订单</li>
            </ul>
        </div>
    </div>
    <div class="main" id="main1">
        <asp:panel id="pnlShopCart" runat="server">
            <div class="cart_content">
                <div class="cart-hd ">
                    <h2>我的购物车</h2>
                    <!--<table width="100%" cellspacing="0" cellpadding="0" border="0">
                        <tbody>
                            <tr>
                                <td width="58%" valign="middle" height="24" align="left">
                                    <div class="cart_prompt">
                                        <span>温馨提示:</span>
                                        如果你记得该商品的货号，可直接输入货号进行添加商品
                                        <%<asp:Literal ID="litNoProduct" runat="server" Text="您的购物车中没有任何商品"></asp:Literal> %>
                                    </div>
                                </td>
                                <td width="1%" valign="middle" align="left"><img src="/images/cart/promptback.jpg" /></td>
                                <td width="31%" valign="middle" align="left"><%<asp:TextBox ID="txtSKU" runat="server" Cssclass="cart_text_input" width="200px" />%> </td>
                                <td width="10%" valign="middle" align="left">
                                    <%<asp:Button ID="btnSKU" runat="server" Cssclass="cart_submit_input" text="添加到购物车" />%>
                                </td>
                            </tr>
                        </tbody>
                    </table>-->
                </div>

                <div class="cart_commodit">
                    <%<hi:common_shoppingcart_productlist runat="server" width="100%" />%>
                    <div style="text-align:right;">
                        <%<asp:Literal ID="lblAmoutPrice" runat="server" />%>
                        <%<asp:HyperLink ID="hlkReducedPromotion" runat="server" />%>
                        <span class="cart_commodit_price3">购物车总计:<span>￥<span><%<Hi:FormatedMoneyLabel ID="lblTotalPrice" runat="server" />%></span></span></span>
                    </div>
                </div>
                <%<hi:common_shoppingcart_promogiftlist runat="server" width="100%" /> %>
                <%<hi:common_shoppingcart_giftlist runat="server" width="100%" />%>
                <div class="cart_commodit_settle">
                    <div class="clear_buycart"><%<Hi:ImageLinkButton ID="btnClearCart" IsShow="true" DeleteMsg="您确认要删除选中的商品吗？" runat="server" Text="删除选中的商品" />%></div>
                    <div class="cart_buy_cartsub"><%<asp:Button ID="btnCheckout" class="cart_chekout" Text="结&nbsp;算" runat="server" OnClientClick="return GoToCheck();" />%>  </div>

                </div>

            </div>

        </asp:panel>
    </div>
    <div class="login_tan" id="loginForBuy" style="display: none;">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td colspan="4">
                    <table class="loginForBuytit" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td width="400">
                                <h2>您尚未登录，请登录</h2>
                            </td>
                            <td width="39">
                                <p>
                                    <img alt="关闭" id="imgCloseLogin" onclick="CloseLogin();" src="http://image.juseshop.com/images/sub/close2.jpg"
                                         width="25" height="24" />
                                </p>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td colspan="4">
                    &nbsp;

                </td>
            </tr>
            <tr>
                <td width="25" valign="middle" w>
                    &nbsp;

                </td>
                <td valign="middle" width="65" class="fB">
                    用户名：
                </td>
                <td width="250" valign="middle">
                    <label>
                        <input type="text" name="textfield" id="textfieldusername" class="login_tan_input1" />
                    </label>
                </td>
                <td valign="middle" width="104">
                    &nbsp;

                </td>
            </tr>
            <tr>
                <td height="45" valign="middle">
                    &nbsp;

                </td>
                <td valign="middle" class="fB">
                    密 码：
                </td>
                <td valign="middle">
                    <input type="password" name="textfield2" id="textfieldpassword" class="login_tan_input2" />
                </td>
                <td valign="middle">
                    <a href="url:ForgotPassword">忘记密码了?</a>
                </td>
            </tr>
            <tr>
                <td colspan="4">
                    <table>
                        <tr>
                            <td width="85" valign="middle">
                                &nbsp;

                            </td>
                            <td width="140">
                                <label>
                                    <input type="button" name="button" id="btnLoginAndBuy" value=" " class="login_tan_input3" />
                                </label>
                            </td>
                            <td width="79" align="center">
                                <a href="url:register">我要注册</a>
                            </td>
                            <td width="135">
                                <input id="btnAmoBuy" type="button" value="匿名购买" />
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        <%<hi:bfdscriptlabel runat="server" />%>
    </div>
    <%<asp:hiddenfield runat="server" id="hfdIsLogin" value="0" />%>
    <%<hi:wnxd_shopcarthistory runat="server" maxnum="5" />%>
    <script type="text/javascript">
        $("#history").children("li").hover(function () {
            $(this).css({
                "border": "1px solid #e43a3b",
                "padding": 2
            }).find(".add_shop_cart").show();
        }, function () {
            $(this).css({
                "border": "",
                "padding": 3
            }).find(".add_shop_cart").hide();
        });
        $('#clearBrowsedProduct').click(function () {
            $.ajax({
                url: "ShoppingHandler.aspx",
                type: "post",
                dataType: "json",
                timeout: 10000,
                data: { action: "ClearBrowsed" },
                async: false,
                success: function (data) {
                    if (data.Status == "Succes") {
                        document.getElementById("history_box").style.display = "none";
                    }
                }
            });
        });
        $(".addToCart").click(function (e) {
            var $this = $(this),
                sku = $this.attr("defaultsku");
            stock = parseInt($this.attr("stock"));
            if (isNaN(stock) || stock <= 0) { stock = 0; }
            if (1 > stock) {
                alert("该商品库存不足1个,不能购买");
                return;
            }
            $.ajax({
                url: "ShoppingHandler.aspx",
                type: 'post', dataType: 'json', timeout: 10000,
                data: { action: "AddToCartBySkus", quantity: 1, productSkuId: sku },
                async: false,
                success: function (resultData) {
                    if (resultData.Status == "OK") {
                        location.reload();
                    } else if (resultData.Status == "0") {
                        alert("此商品已经不存在(可能被删除或被下架)，暂时不能购买");
                    }
                    else if (resultData.Status == "1") {
                        alert("商品库存不足 " + parseInt($("#buyAmount").val()) + " 件，请修改购买数量!");
                    }
                    else {
                        alert(resultData.Status + '66');
                    }
                }
            });
        });
    </script>
    <div class="SearchShoping" style=" margin-top:46px;">
        <div style="text-align: center; line-height: 30px;">您还没有挑选商品，赶快行动吧！ <a style="color: #E60058;" href="/SubCategory.aspx?keywords=">马上去挑选商品&gt;&gt;</a></div>
        <div class="search" style="text-align: center; padding-top: -16px; line-height: 30px; margin-left: 819px">
            <hi:common_search skinname="/ascx/tags/Common_Search/Skin-Common_Search.ascx" id="Common_Search" runat="server" />
        </div>
    </div>
</form>
<%<hi:common_new_footer runat="server" />%>
